package com.uum.blog.service.impl;

import com.uum.blog.pojo.entity.CommentLike;
import com.uum.blog.mapper.CommentLikeMapper;
import com.uum.blog.service.CommentService;
import com.uum.blog.service.CommentLikeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.uum.blog.service.RedisService;
import com.uum.web.util.JwtUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@RequiredArgsConstructor
public class CommentLikeServiceImpl extends ServiceImpl<CommentLikeMapper, CommentLike> implements CommentLikeService {

    private final RedisService redisService;

    @Override
    public Boolean addLike(CommentLike commentLike) {
        Long result = redisService.saveLike(commentLike.getCommentId(), JwtUtils.getUserId());
        return result > 0;
    }

    @Override
    public Long deleteLike(Long commentId,Long userId) {
        Long result = redisService.deleteLike(commentId, userId);
        return result;
    }


}
